package org.ihelpuoo.orm.handler.map;

import java.lang.reflect.Field;
import java.util.Map;

import org.ihelpuoo.lang.ObjectUtils;
import org.ihelpuoo.orm.ObjectRule;
import org.ihelpuoo.orm.handler.ObjectProcessor;
import org.ihelpuoo.orm.handler.SaveNormalFieldHandler;

public class MapSaveNormalFieldHandler extends SaveNormalFieldHandler
{

	public MapSaveNormalFieldHandler(ObjectProcessor beanHandler)
	{
		super(beanHandler);
	}

	@SuppressWarnings("unchecked")
	@Override
	protected void setValueToSourceObject(ObjectRule r, Field f, Object src, Object v)
			throws Exception
	{
		Object value = ObjectUtils.castObjectToCharSequence(v);
		if (null != value)
		{
			String key = r.getAlias(f);
			((Map)src).put(key,value.toString());
		}
	}

}
